package com.sky.mapper.user;

import com.github.pagehelper.Page;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.entity.OrderDetail;
import com.sky.entity.Orders;

import com.sky.vo.OrderVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;


@Mapper
@Repository("userOrderMapper")
public interface OrdersMapper {


    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insert(Orders orders);

    void insertBatch(OrderDetail orderDetail);


    List<Orders> selectById(Long userId, Long id, Long number, Integer status);

    @Select("select * from orders where number = #{orderNumber} and user_id = #{userId} ")
    Orders selectNumberAndUserId(String orderNumber, Long userId);


    void update(Orders orders);


    Page<OrderVO> selectPage(OrdersPageQueryDTO ordersPageQueryDTO);

    @Select("select * from orders where status = #{status} and order_time <= #{orderTime};")
    List<Orders> selectTimeOut(Orders orders);
}
